<template>
    <table border="1">
        <tr>
            <td>会员等级名称</td>
            <td><input type="text" placeholder="请输入名称" v-model="info.Rank_Name"/></td>
        </tr>
        <tr>
            <td>会员等级状态</td>
            <td>
                <input type="radio" :value="true" v-model="info.Rank_State"/>启用
                <input type="radio" :value="false" v-model="info.Rank_State"/>禁用
            </td>
        </tr>
        <tr>
            <td>最小成长值</td>
            <td><input type="text" placeholder="请输入最小成长值" v-model="info.Rank_MinPoint"/></td>
        </tr>
        <tr>
            <td>最大成长值</td>
            <td><input type="text" placeholder="请输入最大成长值" v-model="info.Rank_MaxPoint"/></td>
        </tr>
        <tr>
            <td><input type="button" value="修改" @click="UpdateUser"/></td>
        </tr>
    </table>
</template>
<script setup lang="ts">

    import {ref,onMounted} from 'vue';
    import axios from 'axios';
    import {useRoute,useRouter} from 'vue-router'
    
    const route=useRoute();
    const router=useRouter();
    alert(route.params.id);

    const info=ref({
         Rank_Id:route.params.id,
         Rank_Name: "",
         Rank_State: true,
         Rank_MinPoint: 0,
         Rank_MaxPoint: 0
    });

    onMounted(()=>{
        FanUser();
    })

    const FanUser=()=>{
        axios.get("https://localhost:7153/api/Member/FanMamberRank/ShowMamberRank",{
             params:{
                MRid:route.params.id
             }
        })
        .then(res=>{
            info.value=res.data;
        })
        .catch(err=>{
            console.log(err);
        })
    }
    //修改
    const UpdateUser=()=>{
        axios.put("https://localhost:7153/api/Member/EiditMemberRank/EiditMemberRank",info.value)
        .then(res=>{
            if(res.data>0){
                alert('修改成功');
            }
            else{
                alert('修改失败');
            }
        })
        .catch(err=>{
            console.log(err);
        })
        router.push("/ShowUser");
    }

</script>